package com.sky.orangehireserver.utils;

import org.apache.commons.lang3.StringUtils;

public class StringUtil {

    public static String truncate(String message, int maxLength) {
        if (StringUtils.isBlank(message)) return "";// 若为空 则返回空字符串;
        String trimmed = message.trim(); //去除两侧空白;
        if (trimmed.length() <= maxLength) return trimmed;//如果文本长度小于等于最大长度，直接返回
        return trimmed.substring(0, maxLength);// 截取指定长度
    }
}
